using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableBuffInfExtendDao:DaoBase<TableBuffInfExtend>
    {
        public override void AddPrimaryIndex(TableBuffInfExtend model)
        {
            cachePrimary[model.BuffInfExId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableBuffInfExtend.txt";
        }

        protected override TableBuffInfExtend ParseRowData(string[] rowData)
        {
            TableBuffInfExtend data = new TableBuffInfExtend();
			data.BuffInfExId = rowData [0];
			data.BufferId = rowData [1];
			data.InfFactor = rowData [2];

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.InfValue = 0;
            }
            else
            {
                data.InfValue = double.Parse(rowData[3]);
            }

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.ValueType = 0;
            }
            else
            {
                data.ValueType = int.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.Decay = 0;
            }
            else
            {
                data.Decay = double.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.accum = 0;
            }
            else
            {
                data.accum = double.Parse(rowData[6]);
            }

            return data;
        }


        public override void AddOneIndex(TableBuffInfExtend model)
        {
            if (!cacheOneIndex.ContainsKey(model.BufferId.ToString()))
            {
                cacheOneIndex[model.BufferId.ToString()] = new List<TableBuffInfExtend>();
            }
            cacheOneIndex[model.BufferId.ToString()].Add(model);
        }
    

    }

}
